import sun.reflect.generics.tree.Tree;

public class Demo6 {
    //线程的打断
    private static boolean isQuit = false;//成员变量
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread (() ->{
            while (!isQuit){
                System.out.println("线程工作中");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程工作完毕");
        });

        t.start();
        Thread.sleep(5000);

        isQuit = true;
        System.out.println("设置 isQuit 为 true");
    }
}
